package org.scboy.dbms.valid.datatype;

import java.util.List;

import org.scboy.dbms.annotation.ValidType;
import org.scboy.dbms.entity.ParamConfig;
import org.scboy.dbms.valid.Valid;
import org.scboy.utils.entitys.coobi.Model;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.StrUtil;

@ValidType("身份证")
public class IDCartValid implements Valid {

	@Override
	public List<ParamConfig> config() {
		return null;
	}

	@Override
	public String toString(Model config) {
		return "身份证无效。";
	}

	@Override
	public boolean valid(Object value,Model model, Model config) {
		String data=Convert.toStr(value);
		if(StrUtil.isNotEmpty(data)){
			if(IdcardUtil.isValidCard(data)){
				return true;
			}else{
				return false;
			}
		}else{
			return true;
		}
	}
	
}
